<template>
	<view class="top">
		<view class="list" :class="id=='a'?'active':''" @click="sel">
			<slot></slot>
		</view>
		<view class="list" v-for="(i,index) in nav" :class="id==index?'active':''" @click="checked(i,index)">
			{{i.name}}
		</view>
	</view>
</template>

<script>
	export default {
		name: "navbar",
		data() {
			return {
				id: 'a',
				all:'0'
			};
		},
		props: ['nav'],
		methods: {
			checked(i, index) {
				this.id = index
				this.$emit('switch', i.id)
			},
			sel() {
				this.id = 'a'
				this.$emit('switch', this.all)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.top {
		display: flex;
		justify-content: space-around;
		background: #fff;
		padding: 10rpx 0;

		.list {
			padding-bottom: 5px;
			color: #333;
			font-size: 14px;
			font-weight: bold;
		}

		.active {
			border-bottom: 2px solid #f56946;
		}
	}
</style>
